package com.example.core;

public class Pageable implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private static final int DEFAULT_PAGE_NO = 1;
	private static final int DEFAULT_PAGE_SIZE = 10;

	private int pageNo;// 当前页
	private int pageSize;// 页大小
	private String sort;// 排序

	public Pageable() {
		this(DEFAULT_PAGE_NO, DEFAULT_PAGE_SIZE);
	}

	public Pageable(int pageNo, int pageSize) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	/**
	 * @return 起始位置
	 */
	public int getFromIndex() {
		return (pageNo - 1) * pageSize;
	}

	public Pageable next() {
		return new Pageable(pageNo + 1, pageSize);
	}

}
